package com.bjbn.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bjbn.entity.BridgeAirConditioningInfoHistory;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Delete;

import java.util.Date;

/**
 * 廊桥_飞机空调信息_模型 Mapper 接口
 */
public interface BridgeAirConditioningInfoHistoryMapper extends BaseMapper<BridgeAirConditioningInfoHistory> {

    /**
     * 根据创建时间批量删除过期数据
     * @param createTime 截止时间
     * @param limit 删除数量
     * @return 删除的记录数
     */
    @Delete("DELETE FROM bridge_air_conditioning_info_history WHERE BN_CREATE_TIME < #{createTime} ORDER BY BN_CREATE_TIME LIMIT #{limit}")
    Integer deleteBatchByCreateTimeBefore(@Param("createTime") Date createTime, @Param("limit") Integer limit);

    /**
     * 查询指定时间之前的数据总数
     * @param createTime 截止时间
     * @return 数据总数
     */
    @Select("SELECT COUNT(*) FROM bridge_air_conditioning_info_history WHERE BN_CREATE_TIME < #{createTime}")
    Long countByCreateTimeBefore(@Param("createTime") Date createTime);

}